<?php 

function CT($time)
{
	$diff =  time()-$time;

	if($diff<pow(60, 2)){
		return ceil($diff/pow(60, 1))."分钟之前";
	}elseif($diff<(pow(60, 2)*24)){
		return ceil($diff/pow(60, 2))."小时之前";
	}elseif($diff<(pow(60, 2)*24*7)){
		return ceil($diff/(pow(60, 2)*24))."天之前";
	}else{
		return date("Y-m-d H:i:s",$time);
	}

}

function searchfenci($str)
{
	Vendor('Pscws4.pscws4','','.class.php');
	$pscws = new PSCWS4('utf8');

	$pscws->set_dict('./ThinkPHP/Library/Vendor/Pscws4/etc/dict.utf8.xdb');
	$pscws->set_rule('./ThinkPHP/Library/Vendor/Pscws4/etc/rules.ini');

	$pscws->send_text($str);
	
	$tops = $pscws->get_tops(3, 'n,v');
	$tempArr = array();
	foreach ($tops as  $value) {
		$tempArr[]=$value['word'];
	}
	return $tempArr;
}

function qqmail($to, $title, $content)
{
	// require './PHPMailerAutoload.php';
	Vendor('PHPMailer.PHPMailerAutoload');

	$mail = new PHPMailer;

	//$mail->SMTPDebug = 3;                               // Enable verbose debug output

	$mail->isSMTP();                                      // Set mailer to use SMTP
	$mail->Host = 'smtp.qq.com';  // Specify main and backup SMTP servers
	$mail->SMTPAuth = true;                               // Enable SMTP authentication
	$mail->Username = '113664000@qq.com';                 // SMTP username
	$mail->Password = 'lffujvetrsucbgij';                           // SMTP password
	$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
	$mail->Port = 465;                                    // TCP port to connect to

	$mail->setFrom('113664000@qq.com', '学并思');
	$mail->addAddress('6955044@qq.com', '小马');     // Add a recipient
	// $mail->addAddress('ellen@example.com');               // Name is optional
	$mail->addReplyTo('113664000@qq.com', '学并思');
	// $mail->addCC('cc@example.com');
	// $mail->addBCC('bcc@example.com');

	// $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
	// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
	$mail->isHTML(true);                                  // Set email format to HTML

	$mail->Subject = $title;
	$mail->Body    = $content;
	$mail->AltBody = $content;

	if(!$mail->send()) {
	    echo 'Message could not be sent.';
	    echo 'Mailer Error: ' . $mail->ErrorInfo;
	} else {
	    echo 'Message has been sent';
	}
}

function qq_login()
{

	Vendor('QQconnect.API.qqConnectAPI');
	// require_once("../../API/qqConnectAPI.php");
	$qc = new QC();
	$qc->qq_login();
}


function getOpenid()
{
	Vendor('QQconnect.API.qqConnectAPI');
	$qc = new QC();
	$qc->qq_callback();
	// echo "<br>";
	return $qc->get_openid();
}

function get_qq_user_info()
{
	Vendor('QQconnect.API.qqConnectAPI');
	$qc = new QC();
	return $arr = $qc->get_user_info();
}

?>